#include <bits/stdc++.h>

using namespace std;
#define int long long


void solve()
{
    int n;
    cin >> n;
    int res = 0;
    res += (n / 15) * 3;
    n %= 15;
    for(int i = 0;i <= n;i ++)
    {
        if(i % 3 == i % 5) res++;
    }
    cout << res << endl;
}
signed main()
{
    int t; cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}